<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>计算机组成原理作业管理系统</title>
    <link rel="stylesheet" href="/static/css/layui.css">
</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs layui-bg-black">学生作业管理系统</div>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                    {% if user %}
                    <span>{{ user.name }}</span>
                    {% else %}
                    <span>用户名</span>
                    {% endif %}
                    <dl class="layui-nav-child">
                        <dd><a href="/layout">退出登录</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-more-vertical"></i>
                    </a>
                </li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <script src="/static/layui.js"></script>
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    {% if session.get("role") == "teacher" %}
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">查重管理</a>
                        <dl class="layui-nav-child">
                            <dd class="leftdaohang" data-url="/student/list" mytitle="学生列表">
                                <a>学生列表</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/teacher/list" mytitle="老师列表">
                                <a>老师列表</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/homework/list" mytitle="发布作业">
                                <a>发布作业</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/homework/student/list" mytitle="查看作业">
                                <a>查看作业</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/uploadhomework/teacher_view" mytitle="教师批改">
                                <a>教师批改</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/uploadhomework/ehlist" mytitle="每次作业成绩">
                                <a>每次作业成绩</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/uploadhomework/list" mytitle="所有成绩">
                                <a>所有成绩</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/copy/list" mytitle="学号查找">
                                <a>学号查找</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/copy/list2" mytitle="班级显示">
                                <a>班级显示</a>
                            </dd>
                            <dd class="layui-nav-item leftdaohang" data-url="/copy/echarts" mytitle="图表显示"><a>图表显示</a>
                            </dd>
                        </dl>
                    </li>
                    {% else %}
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">学习管理</a>
                        <dl class="layui-nav-child">
                            <dd class="leftdaohang" data-url="/homework/student/list" mytitle="查看作业">
                                <a>查看作业</a>
                            </dd>
                            <dd class="leftdaohang" data-url="/uploadhomework/list" mytitle="我的成绩">
                                <a>我的成绩</a>
                            </dd>
                        </dl>
                    </li>
                    {% endif %}

                    <!-- 新增：智能分析工具导航组 -->
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">智能分析工具</a>
                        <dl class="layui-nav-child">
                            {% if session.get("role") == "teacher" %}
                            <dd class="layui-nav-item leftdaohang" data-url="/patriotic_prompt/" mytitle="爱国情感分析">
                                <a><i class="layui-icon layui-icon-heart"></i> 爱国情感分析</a>
                            </dd>
                            {% endif %}
                            <dd class="layui-nav-item leftdaohang" data-url="/AI" mytitle="AI检测">
                                <a><i class="layui-icon layui-icon-app"></i> AI检测</a>
                            </dd>
                        </dl>
                    </li>

                    <!-- 保留原有的其他导航项 -->
                    <li class="layui-nav-item leftdaohang" data-url="/question" mytitle="课程知识问答">
                        <a><i class="layui-icon layui-icon-dialogue"></i> 课程知识问答</a>
                    </li>
                    <li class="layui-nav-item leftdaohang" data-url="/document" mytitle="优质英文资料">
                        <a><i class="layui-icon layui-icon-file"></i> 优质英文资料</a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <div class="layui-tab layui-tab-brief" lay-filter="demo" lay-allowclose="true">
                <ul class="layui-tab-title">
                </ul>
                <div class="layui-tab-content">
                </div>
            </div>
        </div>
    </div>
    <script src="/static/jquery-3.6.0.min.js"></script>
    <script>

        layui.use(['element', 'layer', 'util'], function () {
            var element = layui.element,
                layer = layui.layer,
                util = layui.util,
                $ = layui.$;

            var active = {
                tabAdd: function () {
                    //新增一个Tab项
                    var htmlurl = $(this).attr('data-url');
                    var mytitle = $(this).attr('mytitle');
                    //                  alert("触发tab增加事件："+mytitle);
                    //先判断是否已经有了tab
                    var arrayObj = new Array(); //创建一个数组
                    $(".layui-tab-title").find('li').each(function () {
                        var y = $(this).attr("lay-id");
                        arrayObj.push(y);
                    });
                    //                    alert("遍历取到的数组："+arrayObj);
                    var have = $.inArray(mytitle, arrayObj); //返回 3,
                    if (have >= 0) {
                        //tab已有标签
                        //                        alert("遍历的已有标签："+mytitle);
                        element.tabChange('demo', mytitle); //切换到当前点击的页面
                    } else {
                        //没有相同tab
                        //                      alert("遍历的没有相同tab："+mytitle);
                        element.tabAdd('demo', {
                            title: mytitle //用于演示
                            ,
                            content: '<iframe style="width: 100%;height:100%;" frameborder="0" scrolling="yes" src=' + htmlurl +
                                ' ></iframe>',
                            id: mytitle //实际使用一般是规定好的id，这里以时间戳模拟下
                        })

                        element.tabChange('demo', mytitle); //切换到当前点击的页面
                        FrameWH(); //计算框架高度
                    }
                }

            };

            function FrameWH() {
                var h = $(window).height() - 41 - 10 - 60 - 10 - 44 - 10;
                $("iframe").css("height", h + "px");
            }

            $(window).resize(function () {
                FrameWH();
            })

            $(".leftdaohang").click(function () {
                var type = "tabAdd";
                var othis = $(this);
                //                var htmlurl=$(this).attr('data-url');
                //                var mytitle=$(this).attr('mytitle');
                active[type] ? active[type].call(this, othis) : '';
            });

            //头部事件
            util.event('lay-header-event', {
                //左侧菜单事件
                menuLeft: function (othis) {
                    layer.msg('展开左侧菜单的操作', {
                        icon: 0
                    });
                },
                menuRight: function () {
                    layer.open({
                        type: 1,
                        content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                        area: ['260px', '100%'],
                        offset: 'rt' //右上角
                        ,
                        anim: 5,
                        shadeClose: true
                    });
                }
            });
        });

    </script>
</body>

</html>